package com.game.service.game.turntable.config;

import com.game.service.app.Utils;

import java.util.ArrayList;

public class PrizeDailyInfo {
    private int playCounts;
    private String betRatio;
    private ArrayList<PrizeDaily> prizeDailys = new ArrayList<>();

    public ArrayList<PrizeDaily> getPrizeDailys() {
        return prizeDailys;
    }

    public void setPrizeDailys(ArrayList<PrizeDaily> prizeDailys) {
        this.prizeDailys = prizeDailys;
    }

    public int getPlayCounts() {
        return playCounts;
    }

    public void setPlayCounts(int playCounts) {
        this.playCounts = playCounts;
    }

    public void setPlayCountsAdd() {
        this.playCounts += 1;
        //同时更新游戏任务
        for (PrizeDaily prizeDaily : prizeDailys) {
            if (playCounts >= prizeDaily.getPlayCounts()) {
                prizeDaily.setIsSuccess(1);
            }
        }
    }

    public ArrayList<PrizeDaily> exchangePrizeDaily(int prizeDailyCode) {
        ArrayList<PrizeDaily> all = new ArrayList<>();
        for (PrizeDaily prizeDaily : prizeDailys) {
            boolean codeIsTrue = prizeDailyCode == prizeDaily.getPrizeDailyID();//code代码正确
            boolean prizeIsSuccess = prizeDaily.getIsSuccess() == 1;//任务达成
            boolean isSend = prizeDaily.getIsSend() == 0;//礼品未领取
            if (codeIsTrue && prizeIsSuccess && isSend) {
                prizeDaily.setIsSend(1);//发放礼品并且标记已发放
                int mPrizeDiamondSend = Utils.random(prizeDaily.getPrizeDiamondMin(), prizeDaily.getPrizeDiamondMax());
                prizeDaily.setPrizeDiamondSend(mPrizeDiamondSend);
                all.add(prizeDaily);
                return all;
            }
        }
        return null;
    }

    public ArrayList<PrizeDaily> exchangePrizeDailyAll() {
        ArrayList<PrizeDaily> all = new ArrayList<>();
        for (PrizeDaily prizeDaily : prizeDailys) {
            boolean prizeIsSuccess = prizeDaily.getIsSuccess() == 1;//任务达成
            boolean isSend = prizeDaily.getIsSend() == 0;//礼品未领取
            if (prizeIsSuccess && isSend) {
                prizeDaily.setIsSend(1);//发放礼品并且标记已发放
                int mPrizeDiamondSend = Utils.random(prizeDaily.getPrizeDiamondMin(), prizeDaily.getPrizeDiamondMax());
                prizeDaily.setPrizeDiamondSend(mPrizeDiamondSend);
                all.add(prizeDaily);
            }
        }
        return all;
    }

    public String getBetRatio() {
        return betRatio;
    }

    public void setBetRatio(String betRatio) {
        this.betRatio = betRatio;
    }
}
